<%
  #File:    /app/views/manage/users/_form.rhtml
  #Author:  Andrew Stone
  #Created: 08.02.2006
%>

<%=error_messages_for("user")%>  

<%=start_form_tag(:action => form_action)%>

<%=start_large_div_wrapper%>
  <div id="page_title"><%=form_title%></div>
  <div id="large">
    <table>
      <tbody>
      <%
        if current_user_can_manage_user_groups? && @user.role.user_group.length > 0%>
          <tr>
            <td class="list_label">User Group(s):</td>
            <td class="list_data">
              <ul id="user_groups" class="checklist">
              <%
                groups = @user.role.user_group.dup
                i = 0
                groups.each do |grp|
                  bg = row_class(i)
                  i += 1
              %>
                  <%=checklist_li(grp.name,"grp",grp.id,bg,@user.has_user_group_id?(grp.id))%>
              <%
                end
              %>
              </ul>
            </td>
          </tr><%
        end 
      %> 
        <tr>
          <td class="req_label">* First Name:</td>
          <td class="data">
            <%=text_field("user","first_name")%>
          </td>
        </tr>
        <tr>
          <td class="label">Middle Name:</td>
          <td class="data">
            <%=text_field("user","middle_name")%>
          </td>
        </tr>
        <tr>
          <td class="req_label">* Last Name:</td>
          <td class="data">
            <%=text_field("user","last_name")%>
          </td>
        </tr>
        <tr>
          <td class="req_label">* Login:</td>
          <td class="data">
            <% if @user.new_record? %>
                <%=text_field("user","login")%>
            <% else %>
                <%=h(@user.login)%>
            <% end %>
          </td>
        </tr>
        <% 
          if @user.reset_password %>
            <%=render(:partial => "/manage/users/change_password")%><%
          end
        %>
        <% 
          if @user.role.gather_contact_info %>
            <%=render(:partial => "/manage/users/contact_info", :locals => {:edit_user => true})%><%
          end 
        %> 
        <% 
          if @user.role.gather_address_info %>
            <%=render(:partial => "/manage/users/address_info", :locals => {:edit_user => true})%><%
          end 
        %> 
      </tbody>
    </table>
    <%=hidden_field("user","id")%>
    <div id="actions">
      <%=submit_tag("Cancel")%>
      <%
        unless @user.reset_password %>
          <%=submit_tag("Change Password")%><%
        end 
      %>
        <%=submit_tag(capitalize_each_word(form_action.gsub(/_/," ")))%>
    </div>
  </div>
<%=end_div_wrapper%>
<%=end_form_tag%>
